#pragma once

struct view
{
	code c;
	std::vector<code> codes;
	size_t pos = 0;
	std::map<std::wstring, Data> datas;
	std::vector<method_info> methods;
	Data target;
	Data ret;

public:
	void init(object_info);
	void init(Data);
	void init(method_info);
	void init(describe_info, Data&);
private:
	size_t code_pos = 0;
public:
	Token get_token();
	void back(size_t i = 1);
	void set_code(code c);
	bool next_code();
	Data get_target();
};

class application
{
public:
	application(analysis a) :analy(a) {}
public:
	void start();
	void init_view(view& v);
	void remove_view(view& v);
	void work(view& v);
private:
	analysis analy;
	std::stack<view> views;
	view current_view;
	std::map<std::wstring, Data> datas;
private:
	void w_code();
	void w_object();
	void w_method();
	Data w_describe();
private:
	void obj_method_obj(Data&);
	void talk();
private:
	Data get_data();
	Data get_data(std::wstring);
	Data get_data(object_info);
	method_info get_method(std::wstring);
	describe_info get_describe(std::wstring, object_info);
	object_info get_object_info(std::wstring);
};